package com.google.firebase.quickstart.database.custom;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.SimpleItemAnimator;
import android.util.AttributeSet;

import com.stfalcon.chatkit.dialogs.DialogsList;

/**
 * Created by jsb-cpyy on 2018/3/27.
 */

public class MDialogsList extends DialogsList {
    public MDialogsList(Context context) {
        super(context);
    }

    public MDialogsList(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MDialogsList(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public void setAdapter(Adapter adapter) {
        SimpleItemAnimator itemAnimator = new DefaultItemAnimator();
        itemAnimator.setSupportsChangeAnimations(false);

        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
                LinearLayoutManager.VERTICAL, false);
        layoutManager.setReverseLayout(true);
        layoutManager.setStackFromEnd(true);
        setItemAnimator(itemAnimator);
        setLayoutManager(layoutManager);

        super.setAdapter(adapter);
    }
}
